package com.earth.c.controller;

import com.earth.c.render.Result;
import com.jfinal.kit.JsonKit;

public class BaseController {
	public String renderSuccess() {
		return renderJson(new Result(200, "成功！"));
	}

	public String renderSuccess(String message) {
		return renderJson(new Result(200, message));
	}

	public String renderSuccess(String message, Object data) {
		return renderJson(new Result(200, message, data));
	}

	public String renderError() {
		return renderJson(new Result(500, "失败！"));
	}

	public String renderError(String message) {
		return renderJson(new Result(500, message));
	}
	
	public String render401() {
		return renderJson(new Result(401, "会话过期！"));
	}
	


	public String renderJson(Object obj) {
		return JsonKit.toJson(obj);
	}
}
